﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Drawing.Imaging;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using indigo;

namespace dingonettest2
{
   public partial class Form1 : Form
   {
      const String MOLPATH = "../../../../../data/molfiles/";
      Dingo dingo = new Dingo();

      public Form1()
      {
         InitializeComponent();
      }

      private unsafe void Form1_Load(object sender, EventArgs e)
      {
         //dingo.loadMoleculeFromFile(MOLPATH + "complex_DT.mol");
         dingo.loadMolecule("O=C(N(CS)CC)[C@H]1CN([C@@H]2CC3=CNC4=CC=CC(=C34)C2=C1)Cl");
         dingo.setOption("center-double-bond-when-stereo-adjacent", true);
         dingo.setOption("Background-Color", Color.Wheat);
         dingo.setOption("base-color", Color.FromArgb(127, 0, 0));
         dingo.setOption("relative-thickness", 1.7f);
         //dingo.setHDCOffset(100, 100);
      }

      private void Form1_Paint(object sender, PaintEventArgs e)
      {
         try
         {
            Image img = dingo.renderToMetafile(this.ClientRectangle.Width, this.ClientRectangle.Height);
            if (img != null)
               e.Graphics.DrawImageUnscaled(img, new Point(0, 0));
            //dingo.setImageSize(this.ClientRectangle.Width, this.ClientRectangle.Height);
            //dingo.setOutputHDC(e.Graphics.GetHdc());
            //dingo.render();
            //e.Graphics.ReleaseHdc();
         }
         catch (DingoException ex)
         {
            MessageBox.Show(ex.Message, "Dingo Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            Close();
         }
      }

      private void Form1_ClientSizeChanged(object sender, EventArgs e)
      {
         Invalidate();
      }
   }
}
